﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LTHD_Web
{
    public partial class Loadcomment : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int maintopicid = int.Parse(Request["mainid"]);
            int aid = int.Parse(Request.Cookies["userid"].Value);

            dbDataContext db = new dbDataContext();
            var query = from com in db.comments
                        join acc in db.taikhoans on com.taikhoan equals acc.id
                        where com.commentid == maintopicid
                        select new
                        {
                            id = com.id,
                            username = acc.tentaikhoan,
                            message = com.noidung,
                            commenttime = com.date,
                        };
            lb_subcontent.Text = "";
            foreach (var n in query)
            {
                //lb_subcontent.Text += "<div class='fbmaincontent' > <div class='fbstorycontent' ><div class='fbprofileimg' ><a href='#'>    <img src='images/profile1.jpg' width='60px'  /></a>  </div><div class='fbprofilename' > <a href='#'>" + n.username + "</a></div><div class='messageinner' >" + n.message + "</div><div id='subcomment" + n.id + "' class='messageinner' style='color:Gray; '> <a href='#'> Like</a>&nbsp;  <a href='#' > Comment</a> &nbsp; <a href='#'> Share</a> &nbsp;&nbsp; " + n.commenttime + " </div><div class='messageinner' id='subcomment" + n.id + "'> </div></div></div><div style='clear:both'></div>    ";
                lb_subcontent.Text += "<div class='fbsubcontent'><div class='fbsubstorycontent'><div class='fbsubprofileimg'><a href='#'>    <img src='images/profile1.jpg' width='45px'  /></a> </div><div class='submessageinner'> <a href='#'>" + n.username + "</a> " + n.message + "</div><div class='submessageinner' style='color:Gray; '> " + n.commenttime + " <a href='#' style='font-weight:normal'>Like</a></div></div></div>";
            }
            //lb_subcontent.Text += "    <div class='fbsubcontent'>    <div class='fbsubstorycontent'>     <input type='text' name='comment' id='subtextcomment" + maintopicid + "'  style='color:Gray; font-size:13px; width:440px;' value=' Write a comment...' onclick='dosomething(" + maintopicid + ")'/>    <input type='button' name='Subcom' value='Comment' style='font-size:13px' onclick='dosomething(" + maintopicid + ")' />    </div>    </div>    ";
            lb_subcontent.Text += "<div class='fbsubcontent'>    <div class='fbsubstorycontent'> <input type='text' name='comment' id='commentfor" + maintopicid + "'     style='color:Gray; font-size:13px; width:440px;' value=' Write a comment...'         onclick='hidetextbox(" + maintopicid + ")'/>        <input type='button' name='Subcom' value='Comment' style='font-size:13px' onclick='postcomment(" + 1 + "," + aid + "," + maintopicid + ")'/></div></div>";  
    
        }
    }
}